let RecordStatus = require("./suit/audio/record_status").RecordStatus;
let msgType = require("../msgtype");
Component({
  properties: {
    username: {
      type: Object,
      value: {}
    },
    chatType: {
      type: String,
      value: msgType.chatType.SINGLE_CHAT
    }
  },
  data: {
    recordStatus: RecordStatus.HIDE,
    RecordStatus,
    __comps__: {
      main: null,
      emoji: null,
      image: null,
      location: null,
      video: null,
      ptopcall: null
    }
  },
  methods: {
    // 事件有长度限制：仅限 26 字符
    toggleRecordModal() {
      this.triggerEvent("tapSendAudio", null, {
        bubbles: true,
        composed: true
      });
    },
    onMakeVideoCall(evt) {
      this.triggerEvent("makeVideoCall", evt.detail);
    },
    onMakeAudioCall(evt) {
      this.triggerEvent("makeAudioCall", evt.detail);
    },
    sendVideo() {
      this.selectComponent("#chat-suit-video").sendVideo();
    },
    openCamera() {
      this.selectComponent("#chat-suit-video").openCamera();
    },
    openEmoji() {
      this.selectComponent("#chat-suit-emoji").openEmoji();
    },
    cancelEmoji() {
      this.selectComponent("#chat-suit-emoji").cancelEmoji();
    },
    sendImage() {
      this.selectComponent("#chat-suit-image").sendImage();
    },
    sendLocation() {
      // this.data.__comps__.location.sendLocation();
    },
    emojiAction(evt) {
      this.selectComponent("#chat-suit-main").emojiAction(evt.detail.msg);
    },
    callVideo() {
      // console.log("this.data.__comps__.ptopcall", this.data.__comps__.ptopcall);
      console.log("username", this.data.username);
      if (this.data.username.groupId) {
        this.selectComponent("#chat-suit-ptopcall").show("group");
      } else {
        this.selectComponent("#chat-suit-ptopcall").show("contact");
      }
    },
    willSend(data) {
      console.log('will send', data);
      let param = {
        'detail': {
          'msg': data,
          'type': data.type,
        }
      }
      this.props.onNewTextMsg(param);
    },
    antmoveAction: function () {
      //执行时动态赋值，请勿删除
    }
  },
  // lifetimes
  created() {},
  attached() {},
  moved() {},
  detached() {},
  ready() {
    this.setData({
      isIPX: getApp().globalData.isIPX
    });
    // let comps = this.data.__comps__;
    // comps.main = this.selectComponent("#chat-suit-main");
    // comps.emoji = this.selectComponent("#chat-suit-emoji");
    // comps.image = this.selectComponent("#chat-suit-image");
    // comps.ptopcall = this.selectComponent("#chat-suit-ptopcall");
    // // comps.location = this.selectComponent("#chat-suit-location");
    // comps.video = this.selectComponent("#chat-suit-video");
  }
});